import { getSongMenuTag, getSongMenuList } from "../../services/music";
Page({
  data: {
    songMenus: [],
  },
  onLoad() {
    this.fetchAllMenuList();
  },
  // 1.获取tags
  async fetchAllMenuList() {
    const tagRes = await getSongMenuTag();
    const tags = tagRes.tags;
    // 2.根据tags获取对应歌单
    const allPromises = [];
    for (const tag of tags) {
      const promise = getSongMenuList(tag.name);
      allPromises.push(promise);
    }
    Promise.all(allPromises).then((res) => {
      this.setData({
        songMenus: res,
      });
    });
  },
  onShareAppMessage() {
    return {
      title: "Time Music",
      path: "/pages/main-music/main-music",
      imageUrl: "",
    };
  },
});
